package com.wayne.sqlSession;

import com.wayne.config.XMLConfigBuilder;
import com.wayne.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {
  public SqlSessionFactory build(InputStream inputStream) throws PropertyVetoException, DocumentException {
    // 1.使用dom4j解析配置文件，将解析出来的内容封装到Configuration中
    XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
    Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);
    SqlSessionFactory sessionFactory = new DefaultSqlSessionFactory(configuration);
    return sessionFactory;
  }
}
